• 隐藏月日的身份证号逆推


    package 
    {
        import flash.display.Sprite;
        import flash.events.Event;
        
        /**
         * 猜解身份证号
         * 存在的问题是后面不是x的推算准确
         * 是x的有问题
         * @author langxm 964683112@qq.com
         */
        public class Main extends Sprite 
        {
            /**
             * 余数数组
             */
            public var modArr:Array;
            /**
             * 身份证洗漱
             */
            public var modulusArr:Array;
            
            private var id:String;
            
            private var a:int=0, b:int=0, c:int=0, d:int=0;
            
            public function Main(InInput:String='53262819720718326x'):void 
            {
                //this.id = InInput;
                this.id = InInput;
            
                if (stage) init();
                else addEventListener(Event.ADDED_TO_STAGE, init);
            }
            
            private function init(e:Event = null):void 
            {
                removeEventListener(Event.ADDED_TO_STAGE, init);
                // entry point
                //this.id = '370784198902283034';
                
                this.modulusArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
                
                this.modArr = new Array( 1,0, 10, 9, 8, 7, 6, 5, 4, 3, 2);
                
                var sum:int = 0;
                
                for (var index:int = 0; index < 17; index++) {
                    if (this.id.charAt(index)!="*") {
                        sum += (int(id.charAt(index))*this.modulusArr[index]);
                    }
                }
                
                //sum-=
                //if (this.id.charAt(17) == "x")
                var modulus:int = this.id.charAt(17) == "x"?10:int(this.id.charAt(17));
            
                sum -= this.modArr[modulus];
                trace("余数-->"+this.modArr[modulus]);    
                for (var j:int = 0; j < 2; j++) {
                    //trace(j);
                    for (var k:int = 0; k < 9; k++) {
                        //trace();
                        for (var l:int = 0; l < 3; l++) {
                            for (var m:int = 0; m < 9; m++) {
                                
                                if (j + k == 0) continue;
                                if (j == 1 && k > 2) continue;
                                if ((sum + 7 * j + 9 * k + 10 * l + 5 * m)%11==0) {
                                    //trace("A:" + sum + 7 * j + 9 * k + 10 * l + 5 * m);
                                    trace(j+"-"+k+"-"+l+"-"+m);
                                }
                            }
                        }
                            
                    }
                        
                }
                    
            }
            
        }
        
    }
    查看代码

    对车票上隐藏月日的身份证号很感兴趣,于是写了个逆推小算法,不过结尾是x的结果不准确,有待改进

    不过得到的解不是唯一的,一般有十组解左右.

  • 相关阅读:
    2018 dnc .NET Core、.NET开发的大型网站列表、各大公司.NET职位精选,C#王者归来
    下载docker镜像报错,dial tcp x.x.x.x:443: connect: connection refused
    SpringMVC
    MyBatis操作数据库——增删改查
    MyBatis——Mapper配置并查询数据
    MyBatis工程搭建
    测试IOC&DI
    SpringAOP测试
    Spring连接Mysql
    Spring 工程搭建
  • 原文地址:https://www.cnblogs.com/ilangxm/p/3391720.html
Copyright © 2020-2023  润新知