jdk/src/share/classes/sun/security/pkcs11/wrapper/Functions.java
changeset 10336 0bb1999251f8
parent 5506 202f599c92aa
child 12685 8a448b5b9006
equal deleted inserted replaced
10335:3c7eda3ab2f5 10336:0bb1999251f8
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     3  */
     3  */
     4 
     4 
     5 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
     5 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
     6  *
     6  *
     7  * Redistribution and use in  source and binary forms, with or without
     7  * Redistribution and use in  source and binary forms, with or without
   515     public static int hashCode(byte[] array) {
   515     public static int hashCode(byte[] array) {
   516         int hash = 0;
   516         int hash = 0;
   517 
   517 
   518         if (array != null) {
   518         if (array != null) {
   519             for (int i = 0; (i < 4) && (i < array.length); i++) {
   519             for (int i = 0; (i < 4) && (i < array.length); i++) {
   520                 hash ^= ((int) (0xFF & array[i])) << ((i%4) << 3);
   520                 hash ^= (0xFF & array[i]) << ((i%4) << 3);
   521             }
   521             }
   522         }
   522         }
   523 
   523 
   524         return hash ;
   524         return hash ;
   525     }
   525     }
   535     public static int hashCode(char[] array) {
   535     public static int hashCode(char[] array) {
   536         int hash = 0;
   536         int hash = 0;
   537 
   537 
   538         if (array != null) {
   538         if (array != null) {
   539             for (int i = 0; (i < 4) && (i < array.length); i++) {
   539             for (int i = 0; (i < 4) && (i < array.length); i++) {
   540                 hash ^= ((int) (0xFFFF & array[i])) << ((i%2) << 4);
   540                 hash ^= (0xFFFF & array[i]) << ((i%2) << 4);
   541             }
   541             }
   542         }
   542         }
   543 
   543 
   544         return hash ;
   544         return hash ;
   545     }
   545     }
   555     public static int hashCode(CK_DATE date) {
   555     public static int hashCode(CK_DATE date) {
   556         int hash = 0;
   556         int hash = 0;
   557 
   557 
   558         if (date != null) {
   558         if (date != null) {
   559             if (date.year.length == 4) {
   559             if (date.year.length == 4) {
   560                 hash ^= ((int) (0xFFFF & date.year[0])) << 16;
   560                 hash ^= (0xFFFF & date.year[0]) << 16;
   561                 hash ^= (int) (0xFFFF & date.year[1]);
   561                 hash ^= 0xFFFF & date.year[1];
   562                 hash ^= ((int) (0xFFFF & date.year[2])) << 16;
   562                 hash ^= (0xFFFF & date.year[2]) << 16;
   563                 hash ^= (int) (0xFFFF & date.year[3]);
   563                 hash ^= 0xFFFF & date.year[3];
   564             }
   564             }
   565             if (date.month.length == 2) {
   565             if (date.month.length == 2) {
   566                 hash ^= ((int) (0xFFFF & date.month[0])) << 16;
   566                 hash ^= (0xFFFF & date.month[0]) << 16;
   567                 hash ^= (int) (0xFFFF & date.month[1]);
   567                 hash ^= 0xFFFF & date.month[1];
   568             }
   568             }
   569             if (date.day.length == 2) {
   569             if (date.day.length == 2) {
   570                 hash ^= ((int) (0xFFFF & date.day[0])) << 16;
   570                 hash ^= (0xFFFF & date.day[0]) << 16;
   571                 hash ^= (int) (0xFFFF & date.day[1]);
   571                 hash ^= 0xFFFF & date.day[1];
   572             }
   572             }
   573         }
   573         }
   574 
   574 
   575         return hash ;
   575         return hash ;
   576     }
   576     }