@@ 116-123 (lines=8) @@ | ||
113 | * |
|
114 | * @return string The encrypted string. |
|
115 | */ |
|
116 | public static function encrypt( $input, $key = WP2D_ENC_KEY ) { |
|
117 | if ( null === $input || '' === $input ) { |
|
118 | return false; |
|
119 | } |
|
120 | global $wpdb; |
|
121 | ||
122 | return $wpdb->get_var( $wpdb->prepare( 'SELECT HEX(AES_ENCRYPT(%s,%s))', $input, $key ) ); |
|
123 | } |
|
124 | ||
125 | /** |
|
126 | * Decrypt the passed string with the passed key. |
|
@@ 133-140 (lines=8) @@ | ||
130 | * |
|
131 | * @return string The decrypted string. |
|
132 | */ |
|
133 | public static function decrypt( $input, $key = WP2D_ENC_KEY ) { |
|
134 | if ( null === $input || '' === $input ) { |
|
135 | return false; |
|
136 | } |
|
137 | global $wpdb; |
|
138 | ||
139 | return $wpdb->get_var( $wpdb->prepare( 'SELECT AES_DECRYPT(UNHEX(%s),%s)', $input, $key ) ); |
|
140 | } |
|
141 | ||
142 | /** |
|
143 | * Set up and return an API connection using the currently saved options.. |