public class CryptoUtils extends Object
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PUBLIC_KEY_STRING |
Constructor and Description |
---|
CryptoUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
decrypt(PublicKey publicKey,
String cipherText) |
static String |
decrypt(String cipherText) |
static String |
decrypt(String publicKeyText,
String cipherText) |
static String |
encrypt(byte[] keyBytes,
String plainText) |
static String |
encrypt(String plainText) |
static String |
encrypt(String key,
String plainText) |
static String[] |
genKeyPair(int keySize) |
static byte[][] |
genKeyPairBytes(int keySize) |
static PublicKey |
getPublicKey(String publicKeyText) |
static PublicKey |
getPublicKeyByPublicKeyFile(String publicKeyFile) |
static PublicKey |
getPublicKeyByX509(String x509File) |
public static final String DEFAULT_PUBLIC_KEY_STRING
public static String decrypt(String publicKeyText, String cipherText) throws Exception
Exception
public static PublicKey getPublicKeyByPublicKeyFile(String publicKeyFile)
public static String decrypt(PublicKey publicKey, String cipherText) throws Exception
Exception
public static String encrypt(String key, String plainText) throws Exception
Exception
public static String encrypt(byte[] keyBytes, String plainText) throws Exception
Exception
public static byte[][] genKeyPairBytes(int keySize)
public static String[] genKeyPair(int keySize)
Copyright © 2018–2020 baomidou. All rights reserved.