$data Data. */ public static function encrypt_array( array $data ): string { return self::encrypt( (string) wp_json_encode( $data ) ); } /** * Decrypts an array stored with encrypt_array(); [] when unreadable. * * @param string $stored Stored value. * @return array */ public static function decrypt_array( string $stored ): array { $data = json_decode( self::decrypt( $stored ), true ); return is_array( $data ) ? $data : array(); } /** * Masks a secret for display, e.g. "sk-…a1b2". * * @param string $secret Secret. */ public static function mask( string $secret ): string { if ( strlen( $secret ) <= 8 ) { return '' === $secret ? '' : '••••'; } return substr( $secret, 0, 3 ) . '…' . substr( $secret, -4 ); } /** * 32-byte key derived from the site's salts. */ private static function key(): string { return hash( 'sha256', wp_salt( 'secure_auth' ) . '|wpinterface-seo', true ); } }