|
原帖http://bbs.islga.org/read-htm-tid-35011.html[jass]
globals
hashtable udg_StringMatrix
endglobals
function InputStringmatrix takes string s returns nothing //汉字矩阵录入函数
local integer i = 0
local integer j = LoadInteger(udg_StringMatrix,-2,0)
local string str = ""
loop
set str = SubString(s,i * 3,i * 3 + 3)
call SaveStr(udg_StringMatrix,0,j + i,str)
call SaveInteger(udg_StringMatrix,-1,StringHash(str),j + i)
set i = i + 1
exitwhen i > 31
endloop
call SaveInteger(udg_StringMatrix,-2,0,j + 31)
endfunction
function BuildStringMatrix_1 takes nothing returns nothing //汉字矩阵输入 1
call InputStringmatrix("啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘鞍氨安俺按暗岸胺案肮昂盎凹敖熬翱袄")
call InputStringmatrix("傲奥懊澳芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸白柏百摆佰败拜稗斑班")
call InputStringmatrix("搬扳般颁板版扮拌伴瓣半办绊邦帮梆榜膀绑棒磅蚌镑傍谤苞胞包褒剥薄雹")
call InputStringmatrix("保堡饱宝抱报暴豹鲍爆杯碑悲卑北辈背贝钡倍狈备惫焙被奔苯本笨崩绷甭")
call InputStringmatrix("泵蹦迸逼鼻比鄙笔彼碧蓖蔽毕毙毖币庇痹闭敝弊必辟壁臂避陛鞭边编贬扁")
call InputStringmatrix("便变卞辨辩辫遍标彪膘表鳖憋别瘪彬斌濒滨宾摈兵冰柄丙秉饼炳病并玻菠")
call InputStringmatrix("播拨钵波博勃搏铂箔伯帛舶脖膊渤泊驳捕卜哺补埠不布步簿部怖擦猜裁材")
call InputStringmatrix("才财睬踩采彩菜蔡餐参蚕残惭惨灿苍舱仓沧藏操糙槽曹草厕策侧册测层蹭")
call InputStringmatrix("插叉茬茶查碴搽察岔差诧拆柴豺搀掺蝉馋谗缠铲产阐颤昌猖场尝常长偿肠")
call InputStringmatrix("厂敞畅唱倡超抄钞朝嘲潮巢吵炒车扯撤掣彻澈郴臣辰尘晨忱沉陈趁衬撑称")
call InputStringmatrix("城橙成呈乘程惩澄诚承逞骋秤吃痴持匙池迟弛驰耻齿侈尺赤翅斥炽充冲虫")
call InputStringmatrix("崇宠抽酬畴踌稠愁筹仇绸瞅丑臭初出橱厨躇锄雏滁除楚础储矗搐触处揣川")
call InputStringmatrix("穿椽传船喘串疮窗幢床闯创吹炊捶锤垂春椿醇唇淳纯蠢戳绰疵茨磁雌辞慈")
call InputStringmatrix("瓷词此刺赐次聪葱囱匆从丛凑粗醋簇促蹿篡窜摧崔催脆瘁粹淬翠村存寸磋")
call InputStringmatrix("撮搓措挫错搭达答瘩打大呆歹傣戴带殆代贷袋待逮怠耽担丹单郸掸胆旦氮")
call InputStringmatrix("但惮淡诞弹蛋当挡党荡档刀捣蹈倒岛祷导到稻悼道盗德得的蹬灯登等瞪凳")
endfunction
function BuildStringMatrix_2 takes nothing returns nothing //汉字矩阵输入 2
call InputStringmatrix("邓堤低滴迪敌笛狄涤翟嫡抵底地蒂第帝弟递缔颠掂滇碘点典靛垫电佃甸店")
call InputStringmatrix("惦奠淀殿碉叼雕凋刁掉吊钓调跌爹碟蝶迭谍叠丁盯叮钉顶鼎锭定订丢东冬")
call InputStringmatrix("董懂动栋侗恫冻洞兜抖斗陡豆逗痘都督毒犊独读堵睹赌杜镀肚度渡妒端短")
call InputStringmatrix("锻段断缎堆兑队对墩吨蹲敦顿囤钝盾遁掇哆多夺垛躲朵跺舵剁惰堕蛾峨鹅")
call InputStringmatrix("俄额讹娥恶厄扼遏鄂饿恩而儿耳尔饵洱二贰发罚筏伐乏阀法珐藩帆番翻樊")
call InputStringmatrix("矾钒繁凡烦反返范贩犯饭泛坊芳方肪房防妨仿访纺放菲非啡飞肥匪诽吠肺")
call InputStringmatrix("废沸费芬酚吩氛分纷坟焚汾粉奋份忿愤粪丰封枫蜂峰锋风疯烽逢冯缝讽奉")
call InputStringmatrix("凤佛否夫敷肤孵扶拂辐幅氟符伏俘服浮涪福袱弗甫抚辅俯釜斧脯腑府腐赴")
call InputStringmatrix("副覆赋复傅付阜父腹负富讣附妇缚咐噶嘎该改概钙盖溉干甘杆柑竿肝赶感")
call InputStringmatrix("秆敢赣冈刚钢缸肛纲岗港杠篙皋高膏羔糕搞镐稿告哥歌搁戈鸽胳疙割革葛")
call InputStringmatrix("格蛤阁隔铬个各给根跟耕更庚羹埂耿梗工攻功恭龚供躬公宫弓巩汞拱贡共")
call InputStringmatrix("钩勾沟苟狗垢构购够辜菇咕箍估沽孤姑鼓古蛊骨谷股故顾固雇刮瓜剐寡挂")
call InputStringmatrix("褂乖拐怪棺关官冠观管馆罐惯灌贯光广逛瑰规圭硅归龟闺轨鬼诡癸桂柜跪")
call InputStringmatrix("贵刽辊滚棍锅郭国果裹过哈骸孩海氦亥害骇酣憨邯韩含涵寒函喊罕翰撼捍")
call InputStringmatrix("旱憾悍焊汗汉夯杭航壕嚎豪毫郝好耗号浩呵喝荷菏核禾和何合盒貉阂河涸")
call InputStringmatrix("赫褐鹤贺嘿黑痕很狠恨哼亨横衡恒轰哄烘虹鸿洪宏弘红喉侯猴吼厚候后呼")
endfunction
function BuildStringMatrix_3 takes nothing returns nothing //汉字矩阵输入 3
call InputStringmatrix("乎忽瑚壶葫胡蝴狐糊湖弧虎唬护互沪户花哗华猾滑画划化话槐徊怀淮坏欢")
call InputStringmatrix("环桓还缓换患唤痪豢焕涣宦幻荒慌黄磺蝗簧皇凰惶煌晃幌恍谎灰挥辉徽恢")
call InputStringmatrix("蛔回毁悔慧卉惠晦贿秽会烩汇讳诲绘荤昏婚魂浑混豁活伙火获或惑霍货祸")
call InputStringmatrix("击圾基机畸稽积箕肌饥迹激讥鸡姬绩缉吉极棘辑籍集及急疾汲即嫉级挤几")
call InputStringmatrix("脊己蓟技冀季伎祭剂悸济寄寂计记既忌际妓继纪嘉枷夹佳家加荚颊贾甲钾")
call InputStringmatrix("假稼价架驾嫁歼监坚尖笺间煎兼肩艰奸缄茧检柬碱硷拣捡简俭剪减荐槛鉴")
call InputStringmatrix("践贱见键箭件健舰剑饯渐溅涧建僵姜将浆江疆蒋桨奖讲匠酱降蕉椒礁焦胶")
call InputStringmatrix("交郊浇骄娇嚼搅铰矫侥脚狡角饺缴绞剿教酵轿较叫窖揭接皆秸街阶截劫节")
call InputStringmatrix("桔杰捷睫竭洁结解姐戒藉芥界借介疥诫届巾筋斤金今津襟紧锦仅谨进靳晋")
call InputStringmatrix("禁近烬浸尽劲荆兢茎睛晶鲸京惊精粳经井警景颈静境敬镜径痉靖竟竞净炯")
call InputStringmatrix("窘揪究纠玖韭久灸九酒厩救旧臼舅咎就疚鞠拘狙疽居驹菊局咀矩举沮聚拒")
call InputStringmatrix("据巨具距踞锯俱句惧炬剧捐鹃娟倦眷卷绢撅攫抉掘倔爵觉决诀绝均菌钧军")
call InputStringmatrix("君峻俊竣浚郡骏喀咖卡咯开揩楷凯慨刊堪勘坎砍看康慷糠扛抗亢炕考拷烤")
call InputStringmatrix("靠坷苛柯棵磕颗科壳咳可渴克刻客课肯啃垦恳坑吭空恐孔控抠口扣寇枯哭")
call InputStringmatrix("窟苦酷库裤夸垮挎跨胯块筷侩快宽款匡筐狂框矿眶旷况亏盔岿窥葵奎魁傀")
call InputStringmatrix("馈愧溃坤昆捆困括扩廓阔垃拉喇蜡腊辣啦莱来赖蓝婪栏拦篮阑兰澜谰揽览")
endfunction
function BuildStringMatrix_4 takes nothing returns nothing //汉字矩阵输入 4
call InputStringmatrix("懒缆烂滥琅榔狼廊郎朗浪捞劳牢老佬姥酪烙涝勒乐雷镭蕾磊累儡垒擂肋类")
call InputStringmatrix("泪棱楞冷厘梨犁黎篱狸离漓理李里鲤礼莉荔吏栗丽厉励砾历利傈例俐痢立")
call InputStringmatrix("粒沥隶力璃哩俩联莲连镰廉怜涟帘敛脸链恋炼练粮凉梁粱良两辆量晾亮谅")
call InputStringmatrix("撩聊僚疗燎寥辽潦了撂镣廖料列裂烈劣猎琳林磷霖临邻鳞淋凛赁吝拎玲菱")
call InputStringmatrix("零龄铃伶羚凌灵陵岭领另令溜琉榴硫馏留刘瘤流柳六龙聋咙笼窿隆垄拢陇")
call InputStringmatrix("楼娄搂篓漏陋芦卢颅庐炉掳卤虏鲁麓碌露路赂鹿潞禄录陆戮驴吕铝侣旅履")
call InputStringmatrix("屡缕虑氯律率滤绿峦挛孪滦卵乱掠略抡轮伦仑沦纶论萝螺罗逻锣箩骡裸落")
call InputStringmatrix("洛骆络妈麻玛码蚂马骂嘛吗埋买麦卖迈脉瞒馒蛮满蔓曼慢漫谩芒茫盲氓忙")
call InputStringmatrix("莽猫茅锚毛矛铆卯茂冒帽貌贸么玫枚梅酶霉煤没眉媒镁每美昧寐妹媚门闷")
call InputStringmatrix("们萌蒙檬盟锰猛梦孟眯醚靡糜迷谜弥米秘觅泌蜜密幂棉眠绵冕免勉娩缅面")
call InputStringmatrix("苗描瞄藐秒渺庙妙蔑灭民抿皿敏悯闽明螟鸣铭名命谬摸摹蘑模膜磨摩魔抹")
call InputStringmatrix("末莫墨默沫漠寞陌谋牟某拇牡亩姆母墓暮幕募慕木目睦牧穆拿哪呐钠那娜")
call InputStringmatrix("纳氖乃奶耐奈南男难囊挠脑恼闹淖呢馁内嫩能妮霓倪泥尼拟你匿腻逆溺蔫")
call InputStringmatrix("拈年碾撵捻念娘酿鸟尿捏聂孽啮镊镍涅您柠狞凝宁拧泞牛扭钮纽脓浓农弄")
call InputStringmatrix("奴努怒女暖虐疟挪懦糯诺哦欧鸥殴藕呕偶沤啪趴爬帕怕琶拍排牌徘湃派攀")
call InputStringmatrix("潘盘磐盼畔判叛乓庞旁耪胖抛咆刨炮袍跑泡呸胚培裴赔陪配佩沛喷盆砰抨")
endfunction
function GetSingleSecretCharacter takes integer value , integer key , integer checkbit , boolean mode returns string //参数:value:输入的整数(0~2^31-1也就是正整数。)key:验校位和随机位的位置(有效值是0~31,函数会自动求余数。)checkbit:验校值(0~1,函数会自动求余。)mode:验校模式,true时为使用验校码checkbit,false时为奇偶验校。返回值为三个汉字。
local integer array TempBit
local integer TempValue = 0
local integer i = 0
local integer j = 1
local integer k = 0
local string s = ""
set key = key - key / 32 * 32
loop
if i != key and i != key + 1 then
set TempBit = value - value / 2 * 2
set value = value / 2
else
set i = i + 1
endif
set i = i + 1
exitwhen i > 32
endloop
set TempBit[key + 1] = GetRandomInt(0,1)
if mode then
set TempBit[key] = checkbit - checkbit / 2 * 2
else
set i = 0
loop
set TempBit[key] = TempBit[key] + TempBit
set i = i + 1
exitwhen i>32
endloop
set TempBit[key] = TempBit[key] - TempBit[key] / 2 * 2
endif
set i = 0
loop
set j = 1
loop
set TempValue = TempValue + j * TempBit
set j = j * 2
set i = i + 1
exitwhen i > k * 11 + 10
endloop
set s = s + LoadStr(udg_StringMatrix,0,TempValue)
set TempValue = 0
set k = k + 1
exitwhen k > 2
endloop
return s
endfunction
function GetSingleSecretInteger takes string value , integer key , integer checkbit , boolean mode returns integer //参数:value:需解码的字符串(三个汉字。)其他如存入函数。验校失败会返回-1.
local integer array TempArrayInteger
local integer ChrIndex = 0
local integer TempInteger = 0
local integer CheckInt = 0
local integer i = 0
local integer j = 1
loop
set TempInteger = LoadInteger(udg_StringMatrix,-1,StringHash(SubString(value,ChrIndex * 3,ChrIndex * 3 + 3)))
if TempInteger == 0 and SubString(value,ChrIndex * 3,ChrIndex * 3 + 3) != "啊" then//此处的“啊”对应汉字矩阵的0号汉字(第一个)
return -1
endif
set j = 1
loop
set TempArrayInteger = TempInteger - TempInteger / 2 * 2
if i != key then
set CheckInt = CheckInt + TempArrayInteger
endif
set TempInteger = TempInteger / 2
set i = i + 1
set j = j * 2
exitwhen i > ChrIndex * 11 + 10
endloop
set ChrIndex = ChrIndex + 1
exitwhen ChrIndex > 2
endloop
if mode then
if TempArrayInteger[key] != checkbit - checkbit / 2 * 2 then
return -1
endif
else
if TempArrayInteger[key] != CheckInt - CheckInt / 2 * 2 then
return -1
endif
endif
set i = 0
set j = 1
set TempInteger = 0
loop
if i != key and i != key + 1 then
set TempInteger = TempInteger + TempArrayInteger * j
set j = j * 2
endif
set i = i + 1
exitwhen i >32
endloop
return TempInteger
endfunction
[/jass] |
评分
-
查看全部评分
|