`

String public byte[] getBytes()的使用

 
阅读更多

String d1 = " cool "; 
 byte buf  [  ]  = d1.getBytes (  ) ; 
 for  ( int i=0; i < buf.length; i++ )  
  {  
     System.out.println ( " Index " + i + "is : " + buf [ i ]  ) ; 
  }  





public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)


//Use getChars (  )  to copy from one string to another string: 
 src = "Good Morning! How are you?"; 
 char dest [  ]  = new char [ src.length (  )  ] ; 
 src.getChars ( 0, src.length (  ) , dest, 0 ) ; 
 System.out.println ( " Source string: " + src ) ; 
 System.out.print ( " Destination string: " ) ; 
 for  ( int i = 0; i  <  dest.length; i++ )  
    System.out.print ( dest [ i ]  ) ; 
  
  
 RESULT: 
 ======= 
    Source string: Good Morning! How are you? 
    Destination string: Good Morning! How are you? 

Read more: http://kickjava.com/777.htm#ixzz1JMVCzfBc



分享到:
评论

相关推荐

    androidRSA加密

    public static byte[] decryptByPrivateKey(byte[] data, String key) throws Exception { byte[] keyBytes = decryptBASE64(key); PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec( ...

    Java版SMS4和Base64加密算法

    本资源是集合了SMS4和自定义的Base64加密算法。SMS4加密算法中提供了如下接口: private static byte[] encode16(byte[] plain, ...public static String decodeSMS4toString(byte[] cipher, byte[] key); Base64...

    RSA加密解密(C#)实现

    public string RSAEncrypt(string xmlPublicKey, byte[] EncryptString) { try { byte[] CypherTextBArray; string Result; System.Security.Cryptography.RSACryptoServiceProvider rsa = new ...

    DES加密算法DES加密算法

    public byte[] asciitobin(String s) { byte[] A = null; try { MessageDigest md = MessageDigest.getInstance("MD5"); A = md.digest(s.getBytes()); } catch (Exception e) { System.err.println(...

    DES对称分组密码系统的Java实现

    public byte[] Encripting(String plaintext,int i) throws Exception { byte[] bpt=plaintext.getBytes(); Cipher cf = Cipher.getInstance(algo[i]); if(skey==null)this.keyGenerating(); cf.init(Cipher....

    java licence生成例子

    public static byte[] sign(byte[] priKeyText, String plainText) { try { PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(Base64.decode(priKeyText)); KeyFactory keyf = KeyFactory....

    史上最全的java基础总结大全

    public static void main(String[] args) { //编码解码1:默认编码 String str1 = "你好"; byte[] buf1 = str1.getBytes();//默认解码:Unicode,四个字节 //编码解码2:指定编码 String str2 = "你好"; ...

    C#加密JAVA解密

    public static string Encode(string data) { byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(KEY_64); byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(IV_64); ...

    MyEclipse注册机源码

    public static String convert(String s) { if (s == null || s.length() == 0) return s; byte abyte0[] = s.getBytes(); char ac[] = new char[s.length()]; int i = 0; for (int k = abyte0....

    MyEclipse中文字过滤器

    byte[] bytes=input.getBytes("IS08859-1"); return new String(bytes,"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); ...

    IO流的使用,自己的心得

    byte writeStringToBytes[] = writeString.getBytes(); byte temp[] = new byte[tempLength]; //需要几次写入 if(writeStringToBytes.length%tempLength==0) each = writeStringToBytes.length/...

    visual studio 2013 C# DES 加密解密 asp.net 完整 源码 下载

    public static string EncryptDES(string encryptString, string encryptKey) { try { byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8)); byte[] rgbIV = Keys; byte[] inputByteArray =...

    asp.net 通用包

    public static string Encode(string encryptString, string encryptKey) { encryptKey = Utils.GetSubString(encryptKey, 32, ""); encryptKey = encryptKey.PadRight(32, ' '); RijndaelManaged ...

    网站生成密码

    网上下载不知出处 public string MakePassword(string User, string strSite) { try { string strRet = ""; byte[] bStr = new UnicodeEncoding().GetBytes(User); byte[] bKey = new UnicodeEncoding()....

    C#-DES_SAME_JAVA-DES.zip

    public static String desEncrypt(String source, String desKey) throws Exception { try { // 从原始密匙数据创建DESKeySpec对象 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); ...

    commons-codec-1.14.jar

    public static String Encrypt(String sSrc, String sKey) throws Exception { if (sKey == null) { System.out.print("Key为空null"); return null; } // 判断Key是否为16位 if (sKey.length() != 16)...

    C#中压缩字符串

    byte[] data = System.Text.Encoding.UTF8.GetBytes(param); //byte[] data = Convert.FromBase64String(param); MemoryStream ms = new MemoryStream(); Stream stream = new ICSharpCode.SharpZipLib.BZip2....

    加密解密的原理 加密解密的原理

    #region [函数] [加密] ... byte[] Secret_Byte = UTF8Encoding.UTF8.GetBytes(Send_String); string Secret_String = Convert.ToBase64String(Secret_Byte); return Secret_String; } #endregion

    java语言实现3des加密

    public String desDecrypt(String strKey,byte[] result) throws Exception { if(strKey.length() !=16){ for(int i=0;i;i++){ strKey=strKey+DEFAULT_BUMA; } } String key =strKey....

    MD5加密解密

    public string EnCode(string data) { byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(KEY_64); byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(IV_64); DESCryptoServiceProvider ...

Global site tag (gtag.js) - Google Analytics