SJCL库解密问题(SJCL library decryption issue)
当我尝试使用SJCL库进行简单的解密时,我遇到了问题。 我可以很好地加密数据。
在这个例子中,我保存了加密数据,如下所示:
encdata = sjcl.encrypt($('input[name="pass"]').val(), $('textarea[name="cleartxt"]').val());
我将数据放到数据库中。 现在,当我去解密数据时,我从数据库中提取sjcl JSON字符串并通过此函数运行它:
function decryptdata(encdata) { var dpassword = prompt('Decryption Password'); console.log(sjcl.decrypt(dpassword, encdata)); //$('.decrypted').html(dec); }
我在控制台上收到以下错误,它不会超出该sjcl.decrypt语句。
sjcl.js:57 Uncaught TypeError: a.replace is not a function at Object.decode (sjcl.js:57) at Object.decrypt (sjcl.js:56) at decryptdata (my.js:72) at my.php?r=test:13
当然我在这里做了一些明显错误的事情?
I'm having an issue when I attempt to do a simple decryption with the SJCL library. I can encrypt data fine.
In this example I have saved encrypted data like so:
encdata = sjcl.encrypt($('input[name="pass"]').val(), $('textarea[name="cleartxt"]').val());
I ajax the data off to a database. Now when I go to decrypt the data, I pull the sjcl JSON string from my database and run it through this function:
function decryptdata(encdata) { var dpassword = prompt('Decryption Password'); console.log(sjcl.decrypt(dpassword, encdata)); //$('.decrypted').html(dec); }
I get the following error on the console and it won't progress beyond that sjcl.decrypt statement.
sjcl.js:57 Uncaught TypeError: a.replace is not a function at Object.decode (sjcl.js:57) at Object.decrypt (sjcl.js:56) at decryptdata (my.js:72) at my.php?r=test:13
Surely I'm doing something obviously wrong here?
原文:https://stackoverflow.com/questions/45167987
最满意答案
您需要添加www。 您的域的版本到您的etc主机。
127.0.0.1 testsite.com www.testsite.com 127.0.0.1 admin.testsite.com www.admin.testsite.com
You need to add the www. versions of your domains to your etc hosts.
127.0.0.1 testsite.com www.testsite.com 127.0.0.1 admin.testsite.com www.admin.testsite.com
相关问答
更多-
如果你只是想将example.com转换为www.example.com那么你只需要使用: RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=302,NC] 你也可以像这样布置它: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www ...
-
如何在localhost上设置带有和不带www前缀的子域/域(How to setup subdomain/domain with and without www prefix on localhost)[2024-01-20]
您需要添加www。 您的域的版本到您的etc主机。 127.0.0.1 testsite.com www.testsite.com 127.0.0.1 admin.testsite.com www.admin.testsite.com You need to add the www. versions of your domains to your etc hosts. 127.0.0.1 testsite.com www ... -
我制作了一个ASP.NET / C#解决方案。 基本上: private void Application_BeginRequest() { var canonicalAuthority = WebConfigurationManager.AppSettings.Get("CanonicalAuthority") ?? this.Request.Url.Authority; // TODO: Might not work wi ...
-
Plesk WWW前缀(Plesk WWW prefix)[2019-12-27]
什么是服务器的http代码响应? 您可以在“Net”选项卡上的Firebug中查看它。 检查www.mydomain.com是否解析为与mydomain.com相同的IP(nslookup www.mydomain.com) 检查apache的配置是否已应用:apachectl -S / apache2ctl -S | grep www.mydomain.com What is the http code response from server? You can check it in Firebug o ... -
不,这个问题的答案如何在Ubuntu中的localhost上安装SSL? 工作正常。 但是您需要在conf文件中修改几行代码。 我设法现在尝试并且工作正常但我从浏览器收到这条令人恼火的消息,我访问的网站并不安全。 虽然没关系,但因为它只是自签名证书。 在我的/etc/hosts我为本地站点添加了几个子域,因为即使您正确配置了虚拟主机也无法正常工作,因为您的开发站点尚未在线访问。 比如, www.mydomain.com , hello.mydomain.com , world.mydomain.com 现在 ...
-
将www子域转发到域(Forward www subdomain to domain)[2022-02-11]
在你的htaccess文件中使用它 RewriteEngine On RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] In your htaccess file use this RewriteEngine On RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteRu ... -
本地主机上的子域(Subdomain on localhost)[2022-04-18]
你可以尝试一个rewriterule,它将一个子域转换成一个文件夹。 例如,mystuff.localhost变为localhost / mystuff otherthing.localhost/some/dir/here成为localhost/otherthing/some/dir/here You could try a rewriterule, which converts a subdomain into a folder. For example, mystuff.localhost become ... -
将所有根域请求重定向到www。(redirect all root domain request to www. subdomain, keeping the URL intact)[2023-09-05]
如果你正在使用HAProxy 1.5及以上,这应该适合你 单域: acl has_www hdr_beg(host) -i www redirect prefix http://www.example.com code 301 unless has_www 多个域:(脏但有效) # match non www requests: acl has_www hdr_beg(host) -i www. # add a header that says we need to redirect thes ... -
我可以知道它的工作。 一个问题是,那个nginx路由器 listen 443; server_name www.domain.com; 也触发了https://domain.com 。 同时禁用Chrome开发者控制台中的缓存进行测试也是一个巨大的帮助。 完整配置: # main ssl route for www.domain.com server { listen 443; server_name www.domain.com; ssl on; ssl_certifi ...
-
他们指向本地127.0.0.1 不知道为什么,但他们这样做。 They pointing to the local 127.0.0.1 Dont know why, but they do.