{"id":506,"date":"2020-04-16T00:37:00","date_gmt":"2020-04-16T04:37:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=506"},"modified":"2021-01-02T00:38:26","modified_gmt":"2021-01-02T05:38:26","slug":"php-encrypting-and-decrypting","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/php-encrypting-and-decrypting\/","title":{"rendered":"PHP: Encrypting and Decrypting"},"content":{"rendered":"\n<p>The crypt() function provide one-way encryption. Using one-way encryption is like using a key to lock and unlock something. The key is your password.<\/p>\n\n\n\n<p>To encrypt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$pass = 'secret';\n$encrypted = crypt($pass);\n\/\/ $encrypted = $1$zaxz8vXb$.lZaoK40w\/EtrkkogORYo0<\/code><\/pre>\n\n\n\n<p>To decrypt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ entered password\n$pass = 'secret';\n\/\/ $password is the encrypted password\nif (crypt($pass, $encrypted) == $encrypted) {\n  print 'welcome';\n} else {\n  print 'wrong password';\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The crypt() function provide one-way encryption. Using one-way encryption is like using a key to lock and unlock something. The key is your password. To encrypt: To decrypt:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[24],"class_list":["post-506","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=506"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/506\/revisions"}],"predecessor-version":[{"id":507,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/506\/revisions\/507"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}