@Override public byte[] base32Decode( String data ) { return( Base32.decode( data )); }
protected byte[] getRawPublicKey() { return( Base32.decode( public_key )); }
protected void setUID( String str ) { uid = Base32.decode( str ); }
private String decodeKey( String key ) { try{ return( new String( Base32.decode( key ),"UTF-8" )); }catch( Throwable e ){ Debug.out( e); return( "" ); } }
@Override public byte[] getHash() { String base32_hash = result.getHash(); if ( base32_hash != null ){ return( Base32.decode( base32_hash )); } return( null ); }
public boolean verifyPublicKey( String key ) { return( ecc_handler.verifyPublicKey( Base32.decode( key ))); }
public static byte[] decodeSHA1Hash( String str ) { if ( str == null ){ return( null ); } str = str.trim(); byte[] hash = null; try{ if ( str.length() == 40 ){ hash = ByteFormatter.decodeString( str ); }else if ( str.length() == 32 ){ hash = Base32.decode( str ); } }catch( Throwable e ){ } if ( hash != null ){ if ( hash.length != 20 ){ hash = null; } } return( hash ); }
public static void main( String[] args ) { try{ CoreFactory.create(); String short_id = ""; long res = getPopularityBySID( Base32.decode( short_id )); System.out.println( res ); }catch( Throwable e ){ e.printStackTrace(); } } }
@Override public Taggable resolveTaggable( String id ) { if ( id == null ){ return( null ); } return( getDownloadManager( new HashWrapper( Base32.decode( id )))); }
public static byte[] getMapByteArray(Map map, String key, byte[] def) { if (map == null) { return def; } try { Object o = map.get(key); if (o instanceof byte[]) { return (byte[]) o; } String b64Key = key + ".B64"; if (map.containsKey(b64Key)) { o = map.get(b64Key); if (o instanceof String) { return Base64.decode((String) o); } } String b32Key = key + ".B32"; if (map.containsKey(b32Key)) { o = map.get(b32Key); if (o instanceof String) { return Base32.decode((String) o); } } return def; } catch (Throwable t) { Debug.out(t); return def; } }
@Override public void coreRunning(Core core) { List<DownloadManager> listDMS = new ArrayList<>( 1); GlobalManager gm = core.getGlobalManager(); for (Object oDM : listHashes) { if (oDM instanceof String) { String hash = (String) oDM; DownloadManager dm = gm.getDownloadManager(new HashWrapper( Base32.decode(hash))); if (dm != null) { listDMS.add(dm); } } fEntry.setDatasource(listDMS.toArray(new DownloadManager[0])); } } });
protected boolean verify( BuddyPluginBuddy buddy, byte[] payload, byte[] signature ) throws BuddyPluginException { return( verify( buddy.getRawPublicKey(), payload, signature )); }
@Override public void requestAttention( String id ) { DownloadManager dm = getDownloadManager( new HashWrapper( Base32.decode( id ))); if ( dm != null ){ dm.requestAttention(); } }
@Override public void coreRunning(Core core) { GlobalManager gm = core.getGlobalManager(); HashWrapper hw = new HashWrapper(Base32.decode(dmHash)); DownloadManager dm = gm.getDownloadManager(hw); if (dm != null) { fEntry.setDatasource(dm); } } });
@Override public DownloadManager getDownloadManager() { if (dm == null && hash != null) { try { GlobalManager gm = CoreFactory.getSingleton().getGlobalManager(); return gm.getDownloadManager(new HashWrapper(Base32.decode(hash))); } catch (Exception ignore) { } } return dm; }
@Override public boolean mdiEntryDrop(MdiEntry entry, Object payload) { if (!(payload instanceof String)) { return false; } String dropped = (String) payload; String[] split = Constants.PAT_SPLIT_SLASH_N.split(dropped); if (split.length > 1) { String type = split[0]; if (type.startsWith("DownloadManager")) { GlobalManager gm = CoreFactory.getSingleton().getGlobalManager(); for (int i = 1; i < split.length; i++) { String hash = split[i]; try { DownloadManager dm = gm.getDownloadManager(new HashWrapper( Base32.decode(hash))); if (dm != null) { TorrentUtil.assignToCategory(new Object[] { dm }, category); } } catch (Throwable t) { } } } } return true; } });
public cryptoResult decrypt( String public_key, byte[] content ) throws BuddyPluginException { try{ final byte[] decrypted = ecc_handler.decrypt( Base32.decode(public_key), content, "Decrypting message for " + public_key); final Map map = BDecoder.decode( decrypted ); return( new cryptoResult() { @Override public byte[] getChallenge() { return((byte[])map.get("h")); } @Override public byte[] getPayload() { return((byte[])map.get("p")); } }); }catch( Throwable e ){ rethrow( "Decryption failed", e ); return( null ); } }
private void addRemoveDownloads( List<String> hashes, boolean add ) { GlobalManager gm = core.getGlobalManager(); for ( String hash: hashes ){ if ( add ){ DownloadManager download = gm.getDownloadManager( new HashWrapper( Base32.decode( hash ))); if ( download != null ){ int download_up_limit = download.getStats().getUploadRateLimitBytesPerSecond(); int download_down_limit = download.getStats().getDownloadRateLimitBytesPerSecond(); if ( download_up_limit > 0 || download_up_limit < 0 || download_down_limit > 0 || download_down_limit < 0 ){ download_limits.put(hash, new int[]{ download_up_limit, download_down_limit }); } } }else{ download_limits.remove( hash ); } } }
@Override public void deleteResults( String[] result_ids ) { ByteArrayHashMap rids = new ByteArrayHashMap(); for (int i=0;i<result_ids.length;i++){ rids.put( Base32.decode( result_ids[i]), "" ); } boolean changed = false; synchronized( this ){ LinkedHashMap<String,SubscriptionResultImpl> results_map = manager.loadResults( subs ); SubscriptionResultImpl[] results = results_map.values().toArray( new SubscriptionResultImpl[results_map.size()] ); for (int i=0;i<results.length;i++){ SubscriptionResultImpl result = results[i]; if ( !result.isDeleted() && rids.containsKey( result.getKey1())){ changed = true; result.deleteInternal(); } } if ( changed ){ updateReadUnread( results ); manager.saveResults( subs, results ); } } if ( changed ){ saveConfig(SubscriptionListener.CR_RESULTS); } }
/** * @param assetHash the assetHash to set */ public void setAssetHash(String assetHash) { this.assetHash = assetHash; if (assetHash != null) { try { if (gm == null) { gm = CoreFactory.getSingleton().getGlobalManager(); } setDownloadManager(gm.getDownloadManager(new HashWrapper( Base32.decode(assetHash)))); } catch (Exception e) { setDownloadManager(null); Debug.out("Core not ready", e); } } else { setDownloadManager(null); } }