开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 2164|回复: 5
收起左侧

[易源码分享] 没事干 异或加密go版 Delphi版

[复制链接]
结帖率:14% (1/7)
发表于 2020-3-29 14:31:06 | 显示全部楼层 |阅读模式   浙江省金华市
分享源码
界面截图: -
是否带模块: 纯源码
备注说明: -
本帖最后由 chencong5025 于 2020-3-29 14:32 编辑

Delphi版本【10.3.3】

function EncryptStr(const S: WideString; Key: Word): String;
var
  i: Integer;
  RStr: RawByteString;
  RStrB: TBytes Absolute RStr;
begin
  Result := '';
  RStr := UTF8Encode(S);
  for i := 0 to Length(RStr) - 1 do
  begin
    RStrB[i] := RStrB[i] xor (Key shr 8);
    Key := (RStrB[i] + Key) * CKEY1 + CKEY2;
  end;
  for i := 0 to Length(RStr) - 1 do
  begin
    Result := Result + IntToHex(RStrB[i], 2);
  end;
end;
function DecryptStr(const S: String; Key: Word): String;
var
  i, tmpKey: Integer;
  RStr: RawByteString;
  RStrB: TBytes Absolute RStr;
  tmpStr: string;
begin
  tmpStr := UpperCase(S);
  SetLength(RStr, Length(tmpStr) div 2);
  i := 1;
  try
    while (i < Length(tmpStr)) do
    begin
      RStrB[i div 2] := StrToInt('$' + tmpStr[i] + tmpStr[i + 1]);
      Inc(i, 2);
    end; // delphitop.com
  except
    Result := '';
    Exit;
  end;
  for i := 0 to Length(RStr) - 1 do
  begin
    tmpKey := RStrB[i];
    RStrB[i] := RStrB[i] xor (Key shr 8);
    Key := (tmpKey + Key) * CKEY1 + CKEY2;
  end;
  Result := UTF8Decode(RStr);

end;

go语言版本

const CKEY1,CKEY2 =1239,5648

func jiami(da string,Key int) string {
        var RStrB =[]byte(da)
        for i:=0;i<len(RStrB);i++{
                RStrB[i] =byte (int(RStrB[i])^(Key>>8))//Key>>8
                Key = (int(RStrB[i]) + Key) * CKEY1 + CKEY2
}
        return strings.ToTitle(hex.EncodeToString(RStrB))
}
func jiemi(da string,Key int)string{
        var RstrB, _ =hex.DecodeString(da)
        for i :=0;i<len(RstrB);i++{
                tpkey:=RstrB[i]
                RstrB[i] =byte (int(RstrB[i])^(Key>>8))
                Key = (int(tpkey) + Key) * CKEY1 + CKEY2
        }
        return string(RstrB)
}

签到天数: 13 天

发表于 2020-3-30 08:41:24 | 显示全部楼层   重庆市重庆市
了解一下  
回复 支持 反对

使用道具 举报

结帖率:100% (7/7)
发表于 2020-3-30 01:30:29 | 显示全部楼层   广东省中山市
涨知识了
回复 支持 反对

使用道具 举报

签到天数: 14 天

发表于 2020-3-30 00:27:12 | 显示全部楼层   广东省深圳市
我写了个汇编版的
回复 支持 反对

使用道具 举报

结帖率:64% (9/14)

签到天数: 13 天

发表于 2020-3-29 20:57:56 | 显示全部楼层   广东省湛江市
哈哈,不懂delphi
回复 支持 反对

使用道具 举报

结帖率:14% (1/7)
 楼主| 发表于 2020-3-29 14:32:01 | 显示全部楼层   浙江省金华市
Key&gt;&gt;8 是Key>>8
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表