You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Encryption and decryption using cypto

Accepted answer
31
Views
3
Comments
edited Sep 9, 2022 2:59PM in Communication Channels 3 comments

Hi All,

I want to do encryption and decryption, i am referring below document i can able to encrypt but there is no option to decrypt can any one suggest how to decrypt.

Crypto (custhelp.com)

Note: The below line simply print the cipher text with out doing any decrypt process, please check the below code block also

$cipher->decrypt();

$decrypted_text = $cipher->Text;


<?php

// All sample code is Copyright © 2006-2016, Oracle and/or its affiliates.
// All rights reserved. Sample code is provided for training purposes only.
// This sample code is provided "as is" with no warranties of any kind
// express or implied.

/***Authentication***/
require_once(get_cfg_var("doc_root") . "/ConnectPHP/Connect_init.php" );
initConnectAPI("admin", "adminpwd");

/***Use the Crypto versioned namespace***/
use RightNow\Connect\Crypto\v1_4 as Crypto;

try{
	$cipher = new Crypto\AES();  
	$cipher->Mode->ID =1; 
	$cipher->IV->Value = "1234567812345678";
	$cipher->KeySize->LookupName = "128_bits";
	$cipher->Text = "Encrypt this text with AES - MODE CBC";
	$cipher->KeyDerivative = new Crypto\CryptoKeyDerivative();
	$cipher->KeyDerivative->Mode->ID = 2;
	$cipher->KeyDerivative->Salt = new Crypto\CryptoKeyDerivativeSalt();
	$cipher->KeyDerivative->Salt->Value = "abcdefgh";
	$cipher->KeyDerivative->Password = "ABCDEFGHIJKLMNOPQRSTUVWX";
	$cipher->KeyDerivative->Iteration = 1000;
	echo "Text to be encrypted : " .$cipher->Text . "<br>";
	$cipher->encrypt();
	$encrypted_text = $cipher->EncryptedText;
	echo "Encrypted Text : " .base64_encode($encrypted_text)."<br>";

	$cipher->decrypt();
	$decrypted_text
Tagged:

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!