我在 c# 中使用 RSACryptoServiceProvider 生成了公钥:
<RSAKeyValue>
<Modulus>
4kKhD/FWAMtQTRifArfXjxZN+6bOXTkHrVpyz/1wODhSOBqDewoSOFAp5boBd3wFjXszHA+gpUxZNWHRTj898Q==
</Modulus>
<Exponent>
AQAB
</Exponent>
<RSAKeyValue>
Run Code Online (Sandbox Code Playgroud)
这些参数是在 512 位初始化的 RSA 变量中生成的
new RSACryptoServiceProvider(512)
Run Code Online (Sandbox Code Playgroud)
现在,我需要使用这些(模数和指数)来加密一些数据,但是在 groovy 中(SoapUI 测试中的 groovyscript)。在 groovy 中,我正在测试 RSA 加密,对于它的公钥,它只获取十进制数的模数和指数。上面的 Modulus 看起来像一个 base64 字符串,但是当我尝试在 groovy 中解码时,它得到了一些特殊字符,我使用的代码是
byte[] decoded = encoded.decodeBase64()
string s == new String(decoded)
Run Code Online (Sandbox Code Playgroud)
我最终需要的是知道如何使用在 c# 中获得的模数和指数来加密 groovy 中的一些数据。一些帮助如何做到这一点?
我有这个字符串"121,121.00",我需要转换为小数,以给前端这个'121121.00'.我已经尝试了很多,但我还不能做到.这里有一些我试过的代码和他们给我的结果:
string var = "121,121.00"
decimal d = decimal.Parse(var, NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint);
// it gives me '12112100'
decimal d = decimal.Parse(var, NumberStyles.Currency);
// it gives me '12112100'
decimal d = decimal.Parse((var.Replace(",","")), NumberStyles.Currency);
// and it gives me '12112100' too
Run Code Online (Sandbox Code Playgroud)