Questions tagged «securestring»

12
在Node.js中保护随机令牌
在这个问题中, Erik需要在Node.js中生成一个安全的随机令牌。有crypto.randomBytes生成随机缓冲区的方法。但是,node中的base64编码不是网址安全的,它包含/和+而不是-和_。因此,我发现的生成此类令牌的最简单方法是 require('crypto').randomBytes(48, function(ex, buf) { token = buf.toString('base64').replace(/\//g,'_').replace(/\+/g,'-'); }); 有没有更优雅的方式?


4
将安全字符串转换为纯文本
我正在使用PowerShell,并且我有将用户输入的密码成功转换为纯文本的代码: $SecurePassword = Read-Host -AsSecureString "Enter password" | convertfrom-securestring | out-file C:\Users\tmarsh\Documents\securePassword.txt 我尝试了几种将其转换回去的方法,但是似乎都无法正常工作。最近,我尝试了以下方法: $PlainPassword = Get-Content C:\Users\tmarsh\Documents\securePassword.txt #convert the SecureString object to plain text using PtrToString and SecureStringToBSTR $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($PlainPassword) $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($BSTR) #this is an important step to keep things secure 这也给我一个错误。 Cannot convert argument "s", with …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.