如何在DART中转换此习惯的解密Python代码?
我试图获得防火墙遮盖的晦涩的电子邮件。 我在Python中找到了解决方案,但我不知道要在飞镖或颤动中这样做。 这是Python代码
r = int(encodedString[:2],16)
email = ''.join([chr(int(encodedString[i:i+2], 16) ^ r) for i in range(2, len(encodedString), 2)])
return email
print cfDecodeEmail('543931142127353935313e352e7a373b39') # usage
i am trying to get obscured email that was obscured by firewall.
i found the solution in python but i don't know to do this in dart or flutter.
here is the python code
r = int(encodedString[:2],16)
email = ''.join([chr(int(encodedString[i:i+2], 16) ^ r) for i in range(2, len(encodedString), 2)])
return email
print cfDecodeEmail('543931142127353935313e352e7a373b39') # usage
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在python中,
encodedString [:2]
/encodedstring [i:i+2]
从encodedString
中提取两个字符。飞镖等效(假设ASCII字符)将是encodedString.substring(0,2)
和encodedString(i,i,i + 2)
。。
等效于Python的
''。join(list)
in Dart是list.join()
。。python列表综合的等效物(
[i in quote in quote]
)中的dart是collection- for :[for(for for(项目中的var I) )i]
。在范围内(2,len(encodedString),2)在dart中,
python的
等效是使用基本
loop with start,witch,corditi和增量:for
loop,for(var i = 2; i< encodedString.length; i += 2)
。在python中,
int(String,16)
parses字符串
作为十六进制数字。在DART中,使用int.parse(字符串,radix:16)
。在python中,
chr(integer)
从指定的代码点创建一个字符串。飞镖中的等效物为string.fromcharcode(integer)
。将所有这些放在一起:
In Python,
encodedString[:2]
/encodedString[i:i+2]
extract two characters fromencodedString
. The Dart equivalent (assuming ASCII characters) would beencodedString.substring(0, 2)
andencodedString(i, i + 2)
respectively.The equivalent of Python's
''.join(list)
in Dart islist.join()
.The equivalent of a Python's list comprehensions (
[i for i in items]
) in Dart is collection-for
:[for (var i in items) i]
.The equivalent of Python's
for i in range(2, len(encodedString), 2)
in Dart is to use a basicfor
loop with a start, condition, and increment:for (var i = 2; i < encodedString.length; i += 2)
.In Python,
int(string, 16)
parsesstring
as a hexadecimal number. In Dart, useint.parse(string, radix: 16)
.In Python,
chr(integer)
creates a string from the specified code point. The equivalent in Dart isString.fromCharCode(integer)
.Putting it all together: