js进行md5加密

js进行md5加密,js进行md5加密教程如下:

输入一段html代码

实现结果:将代码加密

js实现代码如下:

/**
* @act      code
* @version  1.1
* @author   youngxj
* @date     2018-07-02
* @url      http://www.youngxj.cn
*/

control('璇疯緭鍏ュ唴瀹癸細');

$('#btn_state').click(function () {
	act();
});

/*$('#form-control').blur(function () {
	act();
});*/

$('#base64_image_mult').click(function () {
	base64_image_mult();
});

function act(){
	var val = $('input:radio:checked').val();
	if($('.form-control').val()==''){
		layer.msg('鍐呭娌℃湁濉啓瀹屾暣锛�');
		$('.form-controls').hide();
		return false;
	}
	console.log(val);
	if (val=='urlencode') {
		urlencode();
	}else if(val=='urldecode'){
		urldecode();
	}else if(val=='base64_encode'){
		base64_encode();
	}else if(val=='base64_decode'){
		base64_decode();
	}else if(val=='md5'){
		md5();
	}else if(val=='addslashes'){
		addslashes();
	}else if(val=='stripslashes'){
		stripslashes();
	}else if(val=='base64_image_mult'){
		base64_image_mult();
	}else if(val=='base64_image_url'){
		base64_image_url();
	}else{
		layer.msg('鎰忓鐨勯敊璇紒');
	}
}
function urlencode(){
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?urlencode="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			$("#content").text(data.value);
			$(".form-controls").show();
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}
function urldecode(){
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?urldecode="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			$("#content").text(data.value);
			$(".form-controls").show();
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}
function base64_encode(){
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?base64_encode="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			$("#content").text(data.value);
			$(".form-controls").show();
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}
function base64_decode(){
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?base64_decode="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			$("#content").text(data.value);
			$(".form-controls").show();
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}
function md5(){
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?md5="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			$("#content").text(data.value);
			$(".form-controls").show();
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}
function addslashes(){
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?addslashes="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			$("#content").text(data.value);
			$(".form-controls").show();
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}
function stripslashes(){
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?stripslashes="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			$("#content").text(data.value);
			$(".form-controls").show();
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}


function base64_image_mult() {
	$('#form1').show();
}

function base64_image_url() {
	if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
	$.getJSON("https://api.yum6.cn/code/code.php?base64_image&img="+$('.form-control').val(),function(data){ 
		if (data.code=="200") {
			var base64_url_img = "<img src='"+data.base64_image+"' width='"+data.width+"' height='"+data.height+"'>";
			$(".form-controls").show();
			$(".form-controls").html('<img src="'+data.base64_image+'" width="100%"><br/><label class="control-label" for="inputContent">data url:</label><textarea class="form-control" rows="5" onclick="oCopy(this)" id="form-control">'+data.base64_image+'</textarea><label class="control-label" for="inputContent">css:</label><textarea class="form-control" rows="5" onclick="oCopy(this)" id="form-control">'+base64_url_img+'</textarea>');
			$('#stat').html('涓婁紶瀹屾瘯锛�');
		}else{
			layer.msg('澶辫触锛岃閲嶈瘯锛�');
		}
	});
}

function onprogress(evt){
	  var loaded = evt.loaded;     //宸茬粡涓婁紶澶у皬鎯呭喌 
	  var tot = evt.total;      //闄勪欢鎬诲ぇ灏� 
	  var per = Math.floor(100*loaded/tot);  //宸茬粡涓婁紶鐨勭櫨鍒嗘瘮 
	  layer.msg(per+'%', {
	  	icon: 16
	  	,shade: 0.01
	  });
	}

	function sc(){
var animateimg = $("#file").val(); //鑾峰彇涓婁紶鐨勫浘鐗囧悕 甯�//  
var imgarr=animateimg.split('\\'); //鍒嗗壊  
var myimg=imgarr[imgarr.length-1]; //鍘绘帀 // 鑾峰彇鍥剧墖鍚�  
var houzui = myimg.lastIndexOf('.'); //鑾峰彇 . 鍑虹幇鐨勪綅缃�  
var ext = myimg.substring(houzui, myimg.length).toUpperCase();  //鍒囧壊 . 鑾峰彇鏂囦欢鍚庣紑  
var file = $('#file').get(0).files[0]; //鑾峰彇涓婁紶鐨勬枃浠�  
var fileSize = file.size;           //鑾峰彇涓婁紶鐨勬枃浠跺ぇ灏�  
var maxSize = 10485760;              //鏈€澶�10MB(瀛楄妭)  
if(ext !='.PNG' && ext !='.GIF' && ext !='.JPG' && ext !='.JPEG' && ext !='.BMP'){  
	layer.msg('鏂囦欢绫诲瀷閿欒,璇蜂笂浼犲浘鐗囩被鍨�');  
	return false;  
}else if(parseInt(fileSize) >= parseInt(maxSize)){  
	layer.msg('涓婁紶鐨勬枃浠朵笉鑳借秴杩�10MB');  
	return false;  
}else{
	$('#stat').html('姝e湪涓婁紶');
	var data = new FormData($('#form1')[0]);   
	$.ajax({
		url: "https://api.yum6.cn/code/code.php?base64_image&type=multipart",   
		type: 'POST',    
		data: data,    
		dataType: 'JSON', 
		processData: false,    
		contentType: false,
		xhr: function(){
			var xhr = $.ajaxSettings.xhr();
			if(onprogress && xhr.upload) {
				xhr.upload.addEventListener("progress" , onprogress, false);
				return xhr;
			}
		}
	}).done(function(ret){
		if(ret['code']=='200'){
			var base64_url_img = "<img src='"+ret.base64_image+"' width='"+ret.width+"' height='"+ret.height+"'>";
			$(".form-controls").show();
			$(".form-controls").html('<img src="'+ret.base64_image+'" width="100%"><br/><label class="control-label" for="inputContent">data url:</label><textarea class="form-control" rows="5" onclick="oCopy(this)" id="form-control">'+ret.base64_image+'</textarea><label class="control-label" for="inputContent">css:</label><textarea class="form-control" rows="5" onclick="oCopy(this)" id="form-control">'+base64_url_img+'</textarea>');
			$('#stat').html('涓婁紶瀹屾瘯锛�');
			layer.msg('涓婁紶瀹屾瘯锛�');
		}else{
			layer.msg('涓婁紶澶辫触');  
		}    
	});
	return false;  
};    
}

显示效果:md5在线加密

参考文章:http://www.itmacom.com/gl/33514.html 

快乐下载

软件屋下载

中元手游网

铁盒下载

HTML代码在线运行工具

js代码格式化

js正则表达式测试

进制转换器

ascii码对照表