1 Packagecom.hq.base64;2 3 ImportJava.io.BufferedReader;4 ImportJava.io.FileInputStream;5 Importjava.io.FileNotFoundException;6 ImportJava.io.FileOutputStream;7 Importjava.io.IOException;8 ImportJava.io.InputStreamReader;9 Importjava.io.UnsupportedEncodingException;Ten Importjava.util.Properties; One A ImportJavax.activation.DataHandler; - ImportJavax.activation.DataSource; - ImportJavax.activation.FileDataSource; the Importjavax.mail.Address; - ImportJavax.mail.Authenticator; - ImportJavax.mail.Message; - Importjavax.mail.MessagingException; + Importjavax.mail.PasswordAuthentication; - Importjavax.mail.Session; + ImportJavax.mail.Transport; A ImportJavax.mail.Message.RecipientType; at Importjavax.mail.internet.AddressException; - Importjavax.mail.internet.InternetAddress; - ImportJavax.mail.internet.MimeBodyPart; - ImportJavax.mail.internet.MimeMessage; - ImportJavax.mail.internet.MimeMultipart; - Importjavax.mail.internet.MimeUtility; in - to + - ImportSun.misc.BASE64Encoder; the * Public classBase64util { $ Panax Notoginseng /** - * @paramargs Add by zxx, Dec the * @throwsIOException + */ A Public Static voidMain (string[] args)throwsIOException { theBase64encoder encoder =NewBase64encoder (); +SYSTEM.OUT.PRINTLN ("Please input user name:"); -String username =NewBufferedReader ( $ NewInputStreamReader (system.in)) $ . ReadLine (); - System.out.println (Encoder.encode (Username.getbytes ())); -SYSTEM.OUT.PRINTLN ("Please input password:"); theString Password =NewBufferedReader ( - NewInputStreamReader (system.in))Wuyi . ReadLine (); the System.out.println (Encoder.encode (Password.getbytes ())); - } Wu}
Base64 is one of the most common encoding methods for transmitting 8Bit bytes of code on the network, and you can view rfc2045~rfc2049, which has a detailed specification of MIME. BASE64 encoding can be used to pass longer identity information in an HTTP environment. For example, in the Java Persistence System hibernate, Base64 is used to encode a long unique identifier (typically 128-bit uuid) as a string that is used as a parameter in an HTTP form and an HTTP GET URL. In other applications, it is often necessary to encode binary data as appropriate in the form of URLs (including hidden form fields). At this time, the use of BASE64 encoding is not readable, that is, the encoded data will not be directly visible to the naked eye.
Email Development--base64 Account password conversion