base64java源码_base64com.java 源代码在线查看 - javabase64,是一个基于java的Base64编码程序 资源下载 虫虫电子下载站...

/* * com.twiek.Utils.Base64* package version 1.0, Base64 encoding/decoding utilities * Copyright (C) 2003 Brent "Twiek" Crowe. All rights reserved. * * This file is part of the com.twiek.Utils.Base64* package * * The com.twiek.Utils.Base64* package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */package com.twiek.Utils;import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.IOException;/** * * @version $Revision: 1.0 $ * @author Brent "Twiek" Crowe */public final class Base64Com { private Base64Com() {} public static char menu() { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String buf = ""; char selection = ' '; do { System.out.println(); System.out.println("-----Choose-----"); System.out.println("E)ncode a string"); System.out.println("D)ecode a string"); System.out.println("Q)uit"); System.out.print("Selection: "); try { buf = in.readLine(); } catch(IOException e) {} buf = buf.toUpperCase(); selection = buf.charAt(0); } while(selection != 'E' && selection != 'D' && selection != 'Q'); if(selection == 'Q') { System.out.println("GoodBye!"); System.exit(0); } System.out.println(); return selection; } private static void usage() { System.out.println(); System.out.println("Usage: [-e][-d] "); System.out.println(" -e - Encode String"); System.out.println(" -d - Decode String"); System.out.println(); System.out.println("Without parameters, Base64Com will enter interactive mode"); } private static void copyright() { System.out.println("Base64Com v1.0, Copyright (C) 2003 Brent \"Twiek\" Crowe"); System.out.println("Base64Com comes with ABSOLUTELY NO WARRANTY; for details"); System.out.println("see LICENSE.txt. This is free software, and you are welcome"); System.out.println("to redistribute it under certain conditions; see LICENSE.txt"); System.out.println("for details."); } public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String text, encoded, decoded; char selection; copyright(); if(args.length != 0) { if(!(args[0].equals("-e") || args[0].equals("-d")) || args.length < 2) { usage(); System.exit(0); } else if(args[0].equals("-e")) { System.out.println("Encoding [" + args[1] + "]:"); System.out.println(); System.out.println(Base64.encode(args[1])); } else if(args[0].equals("-d")) { System.out.println("Decoding [" + args[1] + "]:"); System.out.println(); System.out.println(Base64.decode(args[1])); } } else { for(;;) { selection = menu(); if(selection == 'E') { System.out.print("String to encode: "); text = in.readLine(); System.out.println(Base64.encode(text)); } else { System.out.print("String to decode: "); text = in.readLine(); System.out.println(Base64.decode(text)); } } } }}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值