加密在System.Security.Cryptography字母数字 [英] Encryption to alphanumeric in System.Security.Cryptography

查看:264
本文介绍了加密在System.Security.Cryptography字母数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需要的客户ID加密的项目。加密值被用作一个网站,然后完成返回一个个性化形式的查询字符串值

I have a project which requires encryption of customer ids. The encrypted value is used as a query string value for a website which then returns a personalized form for completion.

我遇到的问题是,我们正在与该网站有哪些不允许非字母数字字符的查询字符串的安全策略。

The problem I'm having is that the website we are working with has a security policy which disallows non-alphanumeric characters from a query string.

目前,我想要获得确认到底哪些字符被阻止,但理想的解决办法是使用加密算法,它返回一个字符串。

I'm currently trying to get confirmation of exactly which characters are being blocked, but the ideal solution would be to use an encryption algorithm which returns an alphanumeric string.

我还没有发现任何这样的算法中的System.Security.Cryptography命名空间还没有 - 这显然是因为关键尺寸一般为64位或某些​​多 - 但我希望,这样的算法是可用的。

I haven't found any such algorithm in the System.Security.Cryptography namespace yet - evidently because the key size is generally 64bit or some multiple of - but I'm hoping that such an algorithm is available.

在这个阶段唯一的选择是换出任何字符被视为与其他允许使用的字符非法的,但是我不认为我将有足够的允​​许使用的字符为这个工作。

The only alternative at this stage is to swap out whichever characters are deemed illegal with other allowable characters, however I don't think I'm going to have enough allowable characters for this to work.

做任何事情有这样或建议,就如何处理的经验吗?

Does anything have any experience with this or suggestions on how to proceed?

推荐答案

您只需要在你的允许集中创建任意字节(加密算法的输出)和人物之间的可逆映射。

You just need to create a reversible mapping between arbitrary bytes (the output of the encryption algorithm) and characters in your allowable set.

Base64的工作原理是这样 - 它连接codeS任意的二进制到字符集 [A-ZA-Z0-9 + /] (这是几乎完全你想要什么,增加 + / )。你可能使用Base64编码,然后替换 + / 与其他两个允许的字符,如果有任何(也许 - _ )。

Base64 works like this - it encodes arbitrary binary into characters in the set [A-Za-z0-9+/] (which is almost exactly what you want, with the addition of + and /). You could potentially use Base64 encoding, then replace + and / with two other "allowed characters", if there are any (perhaps - and _?).

应该有现有的Base64编码和解码功能可以在您的语言。

There should be existing Base64 encoding and decoding functions available in your language.

这篇关于加密在System.Security.Cryptography字母数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆